class Exploitdb < Formula
  desc "Database of public exploits and corresponding vulnerable software"
  homepage "https://www.exploit-db.com/"
  url "https://github.com/offensive-security/exploitdb.git",
      tag:      "2021-12-11",
      revision: "55af36c59a073746d8edd219707815074966dd1c"
  version "2021-12-11"
  license "GPL-2.0-or-later"
  head "https://github.com/offensive-security/exploitdb.git", branch: "master"

  bottle do
    sha256 cellar: :any_skip_relocation, arm64_monterey: "31b82904c0c7867225efea240c59f6ede3d0794ead0576810b402da8c1a73464"
    sha256 cellar: :any_skip_relocation, arm64_big_sur:  "f0ca12eba070fe2fc7914e83fde1c302721756df7fe748144589ac2566443976"
    sha256 cellar: :any_skip_relocation, monterey:       "b0b5436c0e799a730e126e93851ea77069f675be79a7e82ef620d17dabf0fe14"
    sha256 cellar: :any_skip_relocation, big_sur:        "3b9f79f60afd076ad2154e36b32a680dd0f0b1599d538257e919bac41b71a96c"
    sha256 cellar: :any_skip_relocation, catalina:       "332d2c574ef83ed2db60c2bcb8cc105e89f498f10ce3cf448f8d6ed3dd7b30bf"
    sha256 cellar: :any_skip_relocation, x86_64_linux:   "f637d592c208faa0fc02afb57e5b81b98f2d55c70545a155effbee3b5a59308a"
  end

  def install
    inreplace "searchsploit",
              "rc_file=\"\"", "rc_file=\"#{etc}/searchsploit_rc\""

    optpath = opt_share/"exploitdb"
    inreplace ".searchsploit_rc" do |s|
      s.gsub! "\"/opt/exploitdb\"", optpath
      s.gsub! "\"/opt/exploitdb-papers\"", "#{optpath}-papers"
    end

    bin.install "searchsploit"
    etc.install ".searchsploit_rc" => "searchsploit_rc"

    pkgshare.install %w[.git exploits files_exploits.csv files_shellcodes.csv
                        shellcodes]
  end

  test do
    system "#{bin}/searchsploit", "sendpage"
  end
end
